N7SD logo

HOME      INDEX

Gnat-GtkAda2020 on Ubuntu Installation



Confirmed Ubuntu versions:
18.04.5 LTS
20.04.1 LTS
Gnat, GtkAda: Adacore 2020
PC: HP Envy-17t-S100


NOTE: These 5 items were processed previously.
~$ sudo apt install gprbuild
~$ sudo ln -s /usr/bin/make /usr/bin/gmake
~$ sudo apt install libncurses5 ——(This is for 20.04.1 LTS)
~$ sudo apt install gcc ——(This is for gtkada build)(Added at 3/29/2021)
~$ sudo apt install make ——(This is for 20.04.1 LTS, when the following error is displayed) (Added at 3/27/2021)


Download GNAT-Community and GtkAda

Adacore download site: https://www.adacore.com/download/more

Select platform: “X86 GNU Linux (64bit)” and Year to download the installers.

Adacore file downloads

Install GNAT Community

Set permission executable the downloaded installer file gnat-2020-20200429-x86-linux-bin.

Double click the application on the file-manager and the sudo ./gnatxxx on the Terminal output the same result.

~/Downloads$ sudo ./gnat-2020-20200429-x86_64-linux-bin 

[sudo] password : (–enter Ubuntu password)

—————————-

NOTE: Error message:
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to ‘/tmp/runtime-root’
–A warning is displayed on the terminal, but ignore it.
If you cannot go forward with the above message on the Terminal, next command can fix it.
export XDG_RUNTIME_DIR=/tmp/runtime-root

—————————-

Next  

[/opt/gtkada] /usr/gnat (–set installation directory)

  Next  Next  Next   Install

Installation here and finished.

This message is displayed on the final screen:

Click to finish the GNAT commmunity

Next  Finish

Installation is finished.

Add PATH bottom of  file ~/.bashrc

——————————————————–   
export PATH=/usr/gnat/bin:$PATH
———————————————————

Re-start Terminal and check PATH

~$ echo $PATH

/usr/gnat/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

~$ sudo apt update
~$ sudo apt upgrade



Test GNAT Community

Build Ada Hello

Create test directory and change directory:
~$ mkdir ada && cd ~/ada && mkdir test1 && cd ~/ada/test1

This is the simplest sample source:

File name: hello.adb

with Ada.Text_IO; use Ada.Text_IO;
procedure Hello is
begin 
Put_Line ("Hello WORLD!");
end Hello;

Build #1, with gnatmake tool: gnatmake hello.adb

hello exec file property

or

Build #2, with gprbuild tool: gprbuild hello.adb

hello exec file property 2

or

Build #3,

  • gcc -c hello.adb
  • gnatbind hello.ali
  • gnatlink hello


If link errors happen as follows, needs to load a package (added 4/1/2021)

$ gnatmake hello.adb
gcc -c hello.adb
gnatbind -x hello.ali
gnatlink hello.ali
/usr/gnat/bin/../libexec/gcc/x86_64-pc-linux-gnu/9.3.1/ld: cannot find crt1.o: No such file or directory
/usr/gnat/bin/../libexec/gcc/x86_64-pc-linux-gnu/9.3.1/ld: cannot find crti.o: No such file or directory
/usr/gnat/bin/../libexec/gcc/x86_64-pc-linux-gnu/9.3.1/ld: cannot find -ldl
/usr/gnat/bin/../libexec/gcc/x86_64-pc-linux-gnu/9.3.1/ld: cannot find -lc
/usr/gnat/bin/../libexec/gcc/x86_64-pc-linux-gnu/9.3.1/ld: cannot find crtn.o: No such file or directory
collect2: error: ld returned 1 exit status
gnatlink: error when calling /usr/gnat/bin/gcc
gnatmake: *** link failed.

Check if crt1.* or crt0.* file are not existing:

$ find /usr/ -name crt1.* —– check if crt1.* existing, but it’s not found
$ find /usr/ -name crt0.* —– check if crt0.* existing, but it’s not found

Install libc6-dev package
$ sudo apt install libc6-dev — install libc6-dev

Build again and confirm if the issue is fixed
$ gnatmake hello.adb –try build again
gcc -c hello.adb
gnatbind -x hello.ali
gnatlink hello.ali
—– Link Passed at this time, Fixed!



Test GNAT Studio IDE


NOTE:

This is for Ubuntu 20.04.1

“gps” was obsolete IDE name and it was switched to “gnatstudio” from GNAT 2020 version.

GNAT2020 with Ubuntu 20.4.1 has some issues to startup in my environment.

a) At the first startup of this application, it takes longer than usual (takes 1 to 2 minutes), but it’s normal.
It can happen at both native and VirtualBox environments.

b) It crashes after $ gnatstudio and Enter, and nothing happen after that.
It needs to cancel the GnatStudio and re-enter it.
It won’t happen again, only at the first time.
It’s only at VirtualBox environment and not 100%.

c) The “Create” window is transparent and Project window’s back-color is black.
It’s only at VirtualBox environment and not 100%.
The symptom can be fixed in this way and they won’t happen again.
Probably the default setting was not set properly.

  1. Choose “Simple Ada Project” and go into “Project” screen.
  2. Edit—Preferences—“Color Theme” tab
  3. Switch theme from “Darkside” to “Default” (you can choose any color)
  4. Close

Startup GNAT Studio: ~/ada/test1$ gnatstudio

GNATStudio  Project selection

Create-new-project

GtkAda—Simple-window Project

test1 default name setting

Paste source text with the same above hello.adb

Build and Run

GNATStudio screen test1

 (Output file size is same the output of gprbuild) 

The project file is created automatically: default.gpr

project Default is
    for Source_Dirs use ("src");
    for Object_Dir use "obj";
    for Main use ("hello.adb");
end Default;


Install GtkAda

Set executable and extract the downloaded package file.

Do installation:

~/Downloads/gtkada-2020-x86_64-linux-bin$ sudo ./doinstall

Password (–enter Ubuntu password)

[/opt/gtkada] /usr/gnat (–set installation directory name. Here same the GNAT)

Y

– – – – – – build – – – – – – – 

The last message:

GtkAda has now been installed on your machine.
You can enter the GtkAda environment by doing:
“/usr/gnat/bin/gtkada-env.sh”


The auto created gtkada-env.sh does not work properly on Ubuntu. We will create new gtkada-env.sh.

GtkAda Environment Setting

Create new gtkada-env.sh file. (This file is same the 2019 version)

————- Create ~/gtkada-env.sh ————————————–

prefix="/usr/gnat"
LD_LIBRARY_PATH_64=$prefix/lib:$LD_LIBRARY_PATH_64 
PKG_CONFIG_PATH=$prefix/lib/pkgconfig:/usr/lib64/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig
GDK_PIXBUF_MODULE_FILE=$prefix/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache
GDK_PIXBUF_MODULEDIR=$prefix/lib/gdk-pixbuf-2.0/2.10.0/loaders/
FONTCONFIG_FILE=$prefix/etc/fonts/fonts.conf
XDG_DATA_DIRS=$prefix/share:$XDG_DATA_DIRS
XDG_CONFIG_DIRS=$prefix/etc:$XDG_CONFIG_DIRS
GSETTINGS_BACKEND=memory
GLADE_BASE_DIR=$prefix
GPR_PROJECT_PATH=$prefix/lib/gnat:$GPR_PROJECT_PATH
export LD_LIBRARY_PATH_64
export PKG_CONFIG_PATH
export GDK_PIXBUF_MODULE_FILE
export GDK_PIXBUF_MODULEDIR
export FONTCONFIG_FILE
export XDG_DATA_DIRS
export XDG_CONFIG_DIRS
export GSETTINGS_BACKEND
export GLADE_BASE_DIR
export GPR_PROJECT_PATH

Add 2 lines (3 include a #comment) at the bottom of ~/.bashrc to call gtkada-en.sh:

#gnat and gtkada
export PATH=/usr/gnat/bin:$PATH
. ./gtkada-env.sh

NOTE . ./gtkada-env.sh     (dot-space-dot-slash gtkada-env.sh)

~$ sudo apt update
~$ sudo apt upgrade

Close console and re-start it.


NOTE: Gedit or some other graphic applications won’t work after the installation of the gtkada-env.sh.




Test Build GtkAda Hello with Gnatstudio

~/ada$ mkdir test2 && cd test2

~/ada/test2$ gnatstudio

Create New Project
GtkAda simple window
GtkAda names test2

Press “Apply” button, then a simple application source is created automatically.

Press “Build-all” and “Run”.

The application Hello window pops up.

GtkAda Hello window test2

Created source file and exec file

hello.adb property
hello exec file property

Automatically created the project file: test_gtkada.gpr

with "gtkada";

project Test_Gtkada is

   for Source_Dirs use ("src");
   for Object_Dir use "obj";
   for Main use ("hello.adb");

end test_Gtkada;


Test Build Testgtk

The application package Testgtk is included in GtkAda and built in the final stage of the installation. It includes most of the GtkAda commands to evaluate their functionalities. We can use it to evaluate or health-check our GtkAda development environment. Each GtkAda command sample is written in a lot of small files in the testgtk directory.

 This is the testgtk package file structure:

testgtk all files tree

1) Copy all of the GtkAda installation files to the other directory.
Here copy to ~/ada/ directory.
~$ cp -r -a ~/Downloads/gtkada-2020-x86_64-linux-bin ~/ada/

2) Move to ada/gtkada-2020-x86_64-linux-bin/testgtk/
Delete 2 object files which were previously created.
testgtk and test_rtree
Delete all of the files in the testgtk/obj directory.

3) Move to the testgtk directory and do gprbuild
~/ada/gtkada-2020-x86_64-linux-bin/testgtk$ gprbuild

testgtk compile and link

The files are created successfully and the file sizes are almost the same.

testgtk original: 15.0 MB (14,952,896 bytes) ===> New file 15.0 MB (14,950,456 bytes)

test_rtee original: 5.6 MB (5,613,968 bytes) ===> New file 5.6 MB (5,613,936 bytes)

 Execute testgtk

~/ada/gtkada-2020-x86_64-linux-bin/testgtk$ ./testgtk

testgtk run

Some warnings and errors are displayed on the console depending on the sample application, but we will neglect them now.

testgtk warnings and errors

Now we finished the Ada and GtkAda installation.